package com.asset.dispoal.file.casedispose.service.command;

import com.asset.dispoal.file.casedispose.dto.FileCaseAddDispocalRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.Collections;

@Component
public class FileCaseAddSingleFileCommand implements BaseCommand<FileCaseAddDispocalRequest, Result> {

    @Autowired
    FileCaseDisposeSaveFileCommand fileCaseDisposeSaveCommand;

    @Override
    public Result execute(FileCaseAddDispocalRequest request) {
        fileCaseDisposeSaveCommand.execute(request.getCaseId(), Collections.singletonList(request.getFile()), request.getCurrentState(), request.getFileType());
        return Result.ok();
    }
}